import json

import requests

url = 'http://httpbin.org/get?name=qiku'
response = requests.get(url, params={
    'age':10,
    'nex':"男",
},headers={
    'user-agent':
    'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36',
})
if response.status_code == 200:
    #低级
    response_bytes = response.content
    response_text = response_bytes.decode('utf-8')
    response_json = json.loads(response_text)
    print( response_json['args'],response_json['headers']['User-Agent'])
#
#
#     # #中级
#     # # print(response.text)
#     # response_json = json.loads(response.text)
#     # print( response_json['args'],response_json['headers']['User-Agent'])
#
#     #高级
#     # print(response.json())
#     print( response.json()['args'],response.json()['headers']['User-Agent'])




# url = 'http://httpbin.org/post?name=qiku'
# response = requests.post(url,headers={
#     'user-agent':
#     'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36',
#     # 配合data
#     # 'Content-Type': 'application/x-www-form-urlencoded',
# },data={'age':10})
# if response.status_code == 200:
#     print(response.json())
#     print(response.request.headers)



# url = 'http://httpbin.org/post?name=qiku'
# response = requests.post(url,headers={
#     'user-agent':
#     'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36',
#     # 配合json
#     # 'Content-Type': 'application/json',
# },json={'age':10})
# if response.status_code == 200:
#     print(response.json())
#     print(response.request.headers)



# url = 'https://contentcms-bj.cdn.bcebos.com/cmspic/bc7bfcbbdc9f43646903046238a87d2a.jpeg?x-bce-process=image/crop,x_0,y_0,w_636,h_346'
# response = requests.get(url)
# if response.status_code == 200:
#     with open('static/test.jpg', 'wb') as f:
#         f.write(response.content)